package com.lqq.designPattern.behavioral_pattern.command;

import java.util.ArrayList;
import java.util.List;

//服务员类（属于请求者角色）
public class Waiter {
    //持有多个命令对象
    private List<Command> commands = new ArrayList<>();

    public void setCommand(Command cmd){
        commands.add(cmd);
    }

    //发起命令的功能 喊 订单来了
    public void orderUp() {
        System.out.println("美女服务员说：大厨，新订单来了...");
        for (Command command : commands) {
            if (command != null) {
                command.execute();
            }
        }
    }

}
